using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace PlayTime
{
    public class Deck
    {
        public const int nPackSize = 52;
        private ArrayList m_cCardPack;
        public Card GetCardFromDeck()
        {
            Card aCard = (Card)m_cCardPack[0];
            m_cCardPack.RemoveAt(0);
            return aCard;
        }

        public void ReturnCardToDeck(Card card)
        {
            m_cCardPack.Add(card);
        }

        public void Shuffle()
        {

            Random random = new Random();
            for (int i = 0; i != m_cCardPack.Count; i++)
            {
                int cardToSwap = random.Next() % m_cCardPack.Count;
                object temp = m_cCardPack[i];
                m_cCardPack[i] = m_cCardPack[cardToSwap];
                m_cCardPack[cardToSwap] = temp;
            }

        }

        public Deck()
        {
            m_cCardPack = new ArrayList(nPackSize);
            foreach (CardSuit cs in CardSuit.GetValues(typeof(CardSuit)))
            {
                foreach (CardType ct in CardType.GetValues(typeof(CardType)))
                {
                    Card aCard = new Card(cs, ct);
                    m_cCardPack.Add(aCard);
                }
            }
        }

        internal int getPackSize()
        {
            return nPackSize;
        }
    }
}
